package com.skydonkey.dao;

import com.skydonkey.pojo.po.Account;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AccountMapper {

    @Select("SELECT * FROM account WHERE uid = #{uid}")
    Account findById(Long uid);

    @Select("SELECT * FROM account WHERE username = #{username}")
    Account findByUsername(String username);

    @Select("SELECT * FROM account")
    List<Account> findAll();

    @Insert("INSERT INTO account(username, nickname, password) " +
            "VALUES(#{username}, #{nickname}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "uid")
    int insert(Account account);

    @Update("UPDATE account SET nickname = #{nickname} where uid = #{uid} ")
    int updateNickname(Account account);

    @Delete("DELETE FROM account WHERE uid = #{uid}")
    int deleteById(Long uid);

    @Delete("UPDATE account SET is_deleted = #{isDeleted} WHERE uid = #{uid}")
    int deleteMarkById(Long uid);
}
